package fr.univ_paris8.iut.linc.align;

import java.net.URI;

public class Entity {
	private String name;
	private URI uri;
	private String label;
	
	
	public Entity(String name) {
		this.name = name;
	}
	
	
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	
	
	public URI getUri() {
		int l = this.getName().length();
		
		if (this.getName().equals("owl:Thing")||(this.getName().equals("rdfs:Literal")))
			uri =  URI.create(this.getName());
		else
			uri = URI.create(this.getName().substring(1, l-1));
		
		return uri;
	}
	
	
	public void setUri(URI uri) {
		this.uri = uri;
	}
	
	
	public String getLabel() {
		if (this.getName().contains("owl:Thing")) 
			label = "owl:Thing";
		else if (this.getName().contains("rdfs:Literal")) 
			label = "rdfs:Literal";
		else
		label = this.getName().substring(this.getName().lastIndexOf("#")+1, this.getName().length()-1) ;
		 
		return label;
	}
	
	
	public void setLabel(String label) {
		this.label = label;
	}
	
	@Override
	public String toString() {
		return "Entity [uri=" + uri + ", label=" + label
				+ "]";
	}


	
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Entity other = (Entity) obj;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		return true;
	}

	
	
}
